package ThreadDome;

public class Dome7 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            for (int i = 0; i < 10; i++) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("后台线程");
            }
        });
        t.setDaemon(true);//设置为后台线程
        t.start();
        for (int i = 0; i < 3; i++) {
            Thread.sleep(1000);
            System.out.println("mian线程启动中");
        }
        System.out.println("main线程结束");
    }
}
